package com.morgan.basemodule.adapter

import androidx.annotation.LayoutRes
import androidx.databinding.ViewDataBinding
import com.chad.library.adapter.base.BaseQuickAdapter
import com.morgan.basemodule.holder.QuickBindingHolder

/**
 *description：
 *<br>author：caowugao
 *<br>time：2021/1/27 0027 18:31
 */
class BindingQuickAdapter<DATA, BINDING : ViewDataBinding>(@LayoutRes layoutResId: Int, data: MutableList<DATA>? = null, private val dataVariableId : Int, private val positionVariableId : Int) : BaseQuickAdapter<DATA, QuickBindingHolder<BINDING>>(layoutResId, data) {

    constructor(@LayoutRes layoutResId: Int, data: MutableList<DATA>? = null, dataVariableId : Int) : this(layoutResId, data, dataVariableId, -1) {

    }
    override fun convert(holder: QuickBindingHolder<BINDING>, item: DATA) {
        holder.bindData(dataVariableId, item, positionVariableId == -1)
        holder.bindData(positionVariableId, holder.adapterPosition, true)
    }

}